package com.example.musictutor.activities;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import com.example.musictutor.R;
import com.example.musictutor.R.layout;
import com.example.musictutor.services.ChartService;
import com.example.musictutor.services.impl.ChartServiceImpl;

import java.util.HashMap;

public class UserProgress extends Activity {

    private ChartService chartService = new ChartServiceImpl();
    private HashMap<String,Integer> progressStatsPerLevel = new HashMap<String, Integer>();
    private boolean passed = true;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(layout.activity_user_progress);
        WebView webview = (WebView) findViewById(R.id.webView1);


        //set the progress level details for level
        progressStatsPerLevel.put("amountOfAttempts",7);
        progressStatsPerLevel.put("amountFailed",5);
        progressStatsPerLevel.put("amountPassed",2);
        progressStatsPerLevel.put("level",1);
        chartService.setProgressLevelStats(progressStatsPerLevel,this);

        String content = chartService.renderUserProgressChartForLevel();

        WebSettings webSettings = webview.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webview.requestFocusFromTouch();
        webview.loadDataWithBaseURL( "file:///android_asset/", content, "text/html", "utf-8", null );
        webSettings.setLoadWithOverviewMode(true);
        webSettings.setUseWideViewPort(true);
        webSettings.setBuiltInZoomControls(true);
        //webview.loadUrl("file:///android_asset/Code.html"); // Can be used in this way too.
    }


}
